import request from './index'

// 登录用的接口
export const LoginAPi = (params: ILoginParams): ResponseData<ILoginResponse> => request.post('/admin/login', params)

// 登录后获取用户权限的接口
export const queryAdminInfoApi = (): ResponseData<IAdminInfoModel> => request.get('/admin/info')

// 用于登出的接口
export const LogoutApi = (): ResponseData<null> => request.post('/admin/logout')

// 分布获取用户列表的接口
export const QueryAdminListApi = (params: IQueryAdminListParams): ResponseData<IQueryAdminData> => request.get('/admin/list', { params })


export const UpdateUserStatusApi = (id: number, status: number): ResponseData<number> => request.post(`/admin/updateStatus/${id}?status=${status}`)

// 添加用户的接口
export const RegUserApi = (params: IRegUserParams): ResponseData<IUserModel> => request.post('/admin/register', params)

// 点击编辑请求最新的用户数据
export const GetUserInfoById = (id: number): ResponseData<IUserModel> => request.get(`/admin/${id}`)

// 确定要修改用户的信息
export const UpdateUserInfoByIdApi = (params: IUserModel): ResponseData<Object> => request.post(`/admin/update/${params.id}`, params)

// 根据用户id获取该用户的所有的角色
export const GetRolesByIdApi = (id: number): ResponseData<IRoleModel[]> => request.get(`/admin/role/${id}`)

// 获取所有的角色
export const GetAllRolesApi = (): ResponseData<IRoleModel[]> => request.get('/role/listAll')

// 分配用户的角色
export const AllocRoleToUserApi = (params: IAllocRaleParams): ResponseData<Object> => request.post(`/admin/role/update?adminId=${params.adminId}&roleIds=${params.roleIds.join(',')}`)

// 这是用于index页面请求 图表数据 的接口
export const GetIndexDataApi = (): ResponseData<IIndexDataModel> => request.get('http://kumanxuan1.f3322.net:8360/admin/stat')